package com.crane.framework.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

/**
 * @author Ten.X
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class RRException extends RuntimeException {
  @Getter @Setter private Integer code;

  private String msg;

  public RRException() {
    super();
  }

  public RRException(String message) {
    super(message);
    this.code = 500;
  }

  public RRException(Integer code, String message) {
    super(message);

    this.code = code;
  }

  public RRException(Throwable cause) {
    super(cause);
  }

  public RRException(String message, Throwable cause) {
    super(message, cause);
  }

  public RRException(
      String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
    super(message, cause, enableSuppression, writableStackTrace);
  }

  @Override
  public String getMessage() {
    return super.getMessage();
  }

  @Override
  public String toString() {
    return this.code + ":" + this.msg;
  }
}
